var arr1 = '111';
console.log(arr1);
if (arr1) {
    console.log(arr1 + typeof (arr1));
}
// 必须给一个泛型, 如果是数组的话.
var arr = [1, 2, 3, 4];
console.log(arr);
// 如果使用的是数组, 可以这样定义的.
var arr2 = [1, 'qqqq'];
console.log(arr2);
// 在定义变量的时候, 就要给一个类型, 因为ts有类型检测机制
var arr3 = ['1', '2', '3'];
console.log(arr3);
// 组合字符串, 拼接字符串
var name1 = 'wangbo';
console.log("hello world " + name1);
// 拼接字符串
var name2 = 'wangbo111';
console.log('你好呀' + name2 + '我爱你呀, 你要好好地');
// 函数返回值可以是 number
var add = function (num1, num2) {
    return num1 + num2;
};
console.log(add(1, 3));
// 返回的是无返回值的
var voidFun = function (num1, num2) {
    console.log('哈哈哈哈哈');
    return;
};
voidFun(1, 5);
// void的变量没有什么用, 只能赋值为undefined 和 null
var unused = undefined;
unused = null;
// 只能声明为undefined 和 null.
// unused = 'hello'
//  任意值
var anyPerson = 'hello';
// anyPerson.setName('bob')
console.log(anyPerson);
// 任意值 , 给any值后面不会报错的.
var myFavoriteNumber = 12;
// 他会自己类型推断的.
// 下面的会报错的.
myFavoriteNumber = '12';
// 还可以联合声明
var unionStr = 12;
unionStr = '242424';
console.log(unionStr);
console.log(typeof unionStr);
// 基本类型
// boolean、string、number、undefined、null
// symbol、promise
// object、array、function
var functionType = function (arr1) {
    console.log(arr1.length);
};
functionType([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
// 接口, 多一个少一个都不行的.
var tom = {
    name: 'bob',
    age: 12,
    addr: '安徽省宣城市宁国市港口镇新时代小区'
};
// 返回的数值
console.log(tom.name + '\n' + tom.age + '\n' + tom.addr);
console.log('姓名:' + tom.name + '\n' + '年纪:' + tom.age + '\n' + '地址:' + tom.addr);
var kate = {
    type: 'cat',
    color: 'white & black'
};
// 定义的对象可以访问
console.log(kate);
console.log(tom);
var apple = {
    id: 1,
    name: 'apple',
    add: '安徽',
    comeFrom: 'mercian'
};
console.log(apple.comeFrom);
console.log(apple.name);
// 定义数组
var arr4 = [1, 2, 3, 4, 5];
var arr5 = arr4.filter(function (n) { return n > 4; });
console.log(arr5);
console.log(arr4.filter(function (n) { return n > 3; }));
// 根据id, 删除数据操作.
var id = 1;
var type = '香蕉';
var arr6 = ['苹果', '香蕉', '葡萄', '梨'];
var chooseReduce = function (obj, type, id) {
    if (id) {
        for (var _i = 0, arr6_1 = arr6; _i < arr6_1.length; _i++) {
            var i = arr6_1[_i];
            if (Number(i) === id) {
                obj = obj.splice(id);
            }
        }
    }
    if (type) {
        obj = obj.filter(function (n) { return n !== type; });
    }
    return obj;
};
var result = chooseReduce(arr6, type, id);
console.log(result);
// 剩余参数
function push1(array) {
    var items = [];
    for (var _i = 1; _i < arguments.length; _i++) {
        items[_i - 1] = arguments[_i];
    }
    console.log(array);
    console.log(items);
}
var array1 = [1, 2, 3, 4, 5];
var x = 10;
var y = 12;
push1(array1, x, y);
function arrPush(arr) {
    var rest = [];
    for (var _i = 1; _i < arguments.length; _i++) {
        rest[_i - 1] = arguments[_i];
    }
    rest.forEach(function (n) {
        arr.push(rest);
    });
    return arr;
}
var arr8 = [1, 2, 3, 4, 5];
var result8 = arrPush(arr8, [1, 2, 3, 4]);
console.log(result8);
function isFish(animal) {
    // 使用断言,as 关键字
    if (typeof animal.swim === 'function') {
        return true;
    }
    return false;
}
var fish1 = {
    name: 'bob',
    swim: function () {
        console.log('swim');
    }
};
var result9 = isFish(fish1);
console.log(result9);
function handle(ele, event) {
    if (ele && event) {
        // 对DOM元素进行、event的方法调用, 进行原生的dom操作.
        this.$listeners(ele, event);
    }
}
// 元祖
var arr10 = [11, 'bob'];
arr[0].toFixed(3);
console.log(arr[0]);
//  元祖后来push进去的数据, 数据类型是元祖中数据的结合.
var arr11 = ['bob', 11, 12];
arr11.push(111);
arr11.push('安徽');
console.log(arr11);
console.log(typeof arr11[0]);
console.log(arr11.length);
console.log(typeof arr11[2]);
// 枚举类型
var num;
(function (num) {
    num[num["one"] = 0] = "one";
    num[num["two"] = 1] = "two";
    num[num["three"] = 2] = "three";
    num[num["four"] = 3] = "four";
    num[num["five"] = 4] = "five";
})(num || (num = {}));
// 可以通过key和value 分别对枚举进行遍历.
console.log(num[0] === 'one');
console.log(num['one'] === 0);
console.log(num);
// 枚举类型中添加其他数值项, 枚举中的数值是无法被改变的, 改变了就会报错了;
var Color;
(function (Color) {
    Color[Color["red"] = 0] = "red";
    Color[Color["blue"] = 1] = "blue";
    Color[Color["white"] = 2] = "white";
})(Color || (Color = {}));
console.log(Color[2]);
console.log(Color[0]);
console.log(Color[1]);
console.log('white'.length);
console.log('this is the first hotUpdate programe');
console.log('this is the first hotUpdate programe');
function add111(num1) {
    console.log('值为%s', num1 * 2);
    return num1 + num1;
}
add111(1);
